﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using FreeSwitch.EventSocket.Parser;

namespace FreeSwitch.EventSocket.Proxy
{
	public class ClientChannel
	{
		private Socket _socket;
		private StringBuffer _buffer = new StringBuffer(4096);
		private byte[] _readBuffer = new byte[4096];

		public ClientChannel(Socket socket)
		{
			_socket = socket;
		}

		public void Start()
		{
			_socket.BeginReceive(_readBuffer, 0, _readBuffer.Length, SocketFlags.None, OnRead, null);
		}

		private void OnRead(IAsyncResult ar)
		{
			int bytesRead;
			try
			{
				bytesRead = _socket.EndReceive(ar);
			}
			catch(Exception err)
			{
				
			}


			_buffer.Append(_readBuffer, 0, bytesRead);


		}
	}
}
